package com.sfac.day6_22.controller;

import com.sfac.day6_22.entity.Covid19;
import com.sfac.day6_22.service.Covid19Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Covid19 Controller
 */
@RestController
@RequestMapping("/api")
public class Covid19Controller {
	@Autowired
	private Covid19Service covid19Service;

	/**
	 * 127.0.0.1:8080/api/covid19s ---- get
	 */
	@GetMapping(value = "/covid19s")
	public List<Covid19> getCovid19sForProvince() {
		return covid19Service.getCovid19sForProvince();
	}

	/**
	 * 127.0.0.1:8080/api/province/covid19s?province=重庆 ---- get
	 */
	@GetMapping(value = "/province/covid19s")
	public List<Covid19> getCovid19sByProvince(
			@RequestParam("province") String province) {
		return covid19Service.getCovid19sByProvince(province);
	}
}
